Skip to content

Conversation

@patrikhuber
Copy link
Contributor

@patrikhuber patrikhuber commented Sep 17, 2025

The previous logic would always add -allow-unsupported-compiler and -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH, even when it was not needed (e.g. when a recent CUDA version is used), and also printing a (confusing) warning which is not applicable in that case.

The revised logic only adds the flags if MSVC>=1940 and CUDA<=12.4. For that, we need to use find_package(CUDAToolkit REQUIRED), like it's also done a few more lines below in the if(BUILD_COMMON_CUDA_ARCHS) code - and then we append to CMAKE_CUDA_FLAGS only when needed.

The new code also uses CMAKE_CUDA_FLAGS for the _ALLOW_COMPILER_AND_STL_VERSION_MISMATCH define, which makes CMake's try_compile (which is used when enable_language(CUDA) is called) work reliably if a CMake version >=3.29.4 is used. It doesn't work when add_compile_definitions(_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH) is used.

Type

  • Bug fix (non-breaking change which fixes an issue): Fixes the issue described above.
  • New feature (non-breaking change which adds functionality). Resolves #
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) Resolves #

Motivation and Context

See above.

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is
      updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test
      results
      (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Description

See above.

The previous logic would always add -allow-unsupported-compiler and -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH, even when it was not needed.
The revised logic only adds the flags if MSVC>=1940 and CUDA<=12.4. The new code also uses CMAKE_CUDA_FLAGS for the define, which makes CMake's try_compile work reliably if a CMake version >=3.29.4 is used.
@update-docs
Copy link

update-docs bot commented Sep 17, 2025

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

@patrikhuber
Copy link
Contributor Author

@ssheorey could we get this merged?

@patrikhuber
Copy link
Contributor Author

@ssheorey Anything I can do to get this merged?

Copy link
Member

@ssheorey ssheorey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @patrikhuber I simplified the update by removing the duplicate flag check. Duplicate flags should be harmless.

@ssheorey ssheorey merged commit f609976 into isl-org:main Oct 29, 2025
5 of 29 checks passed
@patrikhuber
Copy link
Contributor Author

Thanks @patrikhuber I simplified the update by removing the duplicate flag check. Duplicate flags should be harmless.

Thanks for merging! I personally think the version with the check is better (and only marginally longer), as the version you merged will add those two flags every time CMake configure is run (which can be very often!). However, maybe one argument for your stripped down version is that medium-term everyone is going to be at CUDA above version 12.5, so this will not be needed anymore anyway (and the flags aren't added for anyone already on CUDA > 12.5 anyway).

@patrikhuber patrikhuber deleted the fix-nvcc-allow-unsupported-compiler-logic branch October 30, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants